package com.iv.durian.cloud;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

@ApiModel(value="执行结果",description="通用结果对象")
public class JsonResult<T> {
    @ApiModelProperty(value="数据",name="data",example="{}/[]/null")
    private T data;
    @ApiModelProperty(value="执行状态",name="status",example="200 正常 500 异常")
    private int status = 200;
    @ApiModelProperty(value="异常消息",name="message",example="用户不存在")
    private String message = StringUtils.EMPTY;

    public JsonResult(){
    }

    public JsonResult(T data){
        this.data = data;
    }

    public JsonResult(int status, String message){
        this.status = status;
        this.message = message;
    }

    public void ok(T data){
        this.data = data;
    }

    public void error(String message){
        this.error(message,500);
    }

    public void error(String message,int status){
        this.message = message;
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }
}
